﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Text;
using System.Windows.Forms;

namespace Lyon.Register.WinForm
{
    partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RegisterInfo info = new RegisterInfo();
            info.UserName = textBox3.Text;
            info.AppName = textBox1.Text;
            info.IsEnableMachineCode = checkBox2.Checked;
            info.MachineCode = textBox2.Text;
            info.IsEnableLimit = checkBox3.Checked;
            info.Limit = dateTimePicker1.Value;
            info.LastVisitDate = DateTime.Now;

            string license = RegisterInfo.GetStr(info);
            license = EncryptUtil.Encrypt(license, info.UserName);
            if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.File.WriteAllText(saveFileDialog1.FileName, license);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            RegisterInfoForm view = new RegisterInfoForm();
            view.ShowDialog();
        }
    }
}
